<template>
  <a-modal :title="title" style="top: 100px;" :visible="true" width="1100px" @cancel="handleCancel">
    <a-table class="product-table" :rowKey="row => row.id" :dataSource="list" bordered :pagination="pagination" size="small">
      <a-table-column title="直推用户" width="140px">
        <template slot-scope="row">
          <div class="user">
            <img :src="row.user.headimg" class="thumb" alt="用户头像">
            <div>
              <div>{{row.user.name}}</div>
              <div>{{row.user.phone}}</div>
            </div>
          </div>
        </template>
      </a-table-column>
      <a-table-column title="注册时间" width="100px">
        <template slot-scope="row">
          <div>{{row.user.created_at}}</div>
        </template>
      </a-table-column>	  
      <a-table-column title="72小时消费金额" key="number2" width="100px">
        <template slot-scope="row">
          <div>
            <NumberGroupDisplay :info="row" prefix="day3_pay_"></NumberGroupDisplay>
          </div>
        </template>
      </a-table-column>
      
      <a-table-column title="首月消费金额" key="number3" width="100px">
        <template slot-scope="row">
          <div>
            <NumberGroupDisplay :info="row" prefix="first_month_pay_"></NumberGroupDisplay>
          </div>
        </template>
      </a-table-column>

    </a-table>
    <template slot="footer">
      <div class="btn-c">
        <div style="flex-grow: 1;"></div>
        <a-button key="back" @click="handleCancel">关闭</a-button>
      </div>
    </template>
  </a-modal>
</template>
<script>
  import UploadImages from '@/components/UploadImages/UploadImages'
  import iSwitch from '@/components/ISwitch/ISwitch'
  import ISkuType from '@/components/ISkuType/ISkuType'
  import NumberGroupDisplay from '@/views/stats/components/NumberGroupDisplay'
  
  export default {
    components: {
      UploadImages,
      iSwitch,
      ISkuType,
      NumberGroupDisplay
    },
    props: {
      info: {
        type: Object,
        default () {
          return {}
        }
      }
    },
    data() {
      return {
        title: '',
        title2: '',
        session: {},
        reward: [],
        page: 1,
        per_page: 10,
        total: 0,
        rankTypeList: [
          {
            type: 1,
            title: '社群推广每月绩效-奖励明细',
          },
          {
            type: 2,
            title: '社群推广每周绩效',
          }
        ],
        list: [],
      }
    },
    watch: {
      uuid() {
        this.initList()
      },
    },
    computed: {
      pagination() {
        return {
          defaultPageSize: this.per_page,
          defaultCurrent: this.page,
          total: this.total,
          onChange: (e) => {
            this.page = e
            this.initList()
          }
        }
      }
    },
    created() {
      this.initList()
      let item = this.rankTypeList;
      let now_type = this.rankTypeList.find(item => item.type === this.info.rank_type)
      this.title = `${this.info.session.session}【${this.info.user.name} - ${this.info.user.phone}】${now_type.title}`
      this.title2 = now_type.title
    },
    methods: {
      initList() {
        this.$http.get(`/agent/month-commission/record`, {
          params: {
            page: this.page,
            per_page: this.per_page,
            commission_id: this.info.commission_id
          }
        }).then(res => {
          this.list = res.data.list
          this.total = res.data.item_total
        })
      }, 
      handleCancel() {
        this.$emit('hide')
      },
      handleSave() {
        this.$emit('refresh')
        this.$emit('close')
        // this.$http.put(`/activities/${this.uuid}/skus/batch`, {
        //   list: this.list
        // }).then(res => {
        //   this.$message.success('保存成功')
        //   this.initList()
        // })
      },
    }
  }
</script>
<style lang="less" scoped>
  .user {
    display: flex;
    // flex-wrap: wrap;
    align-items: center;
  
    img {
      width: 26px;
      height: 26px;
      margin-right: 6px;
      border-radius: 50%;
      overflow: hidden;
    }
    }
  .thumb {
    width: 30px;
    // height: 60px;
    border-radius: 6px;
  }
  .btn-c {
    display: flex;
    // margin-top: 30px;
    padding: 0rpx 30rpx;

    .add {}

    .save {
      margin-right: 20px;
    }

    .cancel {}
  }

  .tips {
    color: gray;
    font-size: 16px;
    margin-bottom: 6px;
  }

  a-input {
    display: inline;
  }
</style>
